package top.kaoshanji.r6ch13a;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

/**
 * 代码清单-r6ch13a-429a：JdbcTemplate的第一个示例
 * @author kaoshanji
 * ^_^
 * create time 2025/5/11 17:28
 */
public class FirstJdbcTemplateExample {

    public static void main(String[] args) {

        // 创建一个数据源
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://localhost:5500/Code-Learn-can2025012603-version1?useUnicode-true&serverTimezone=UTC&allowpublicKeyRetrieval-true&characterEncoding-utf8&usessL-false");
        dataSource.setUsername("xxxppp");
        dataSource.setPassword("P!14.b@1k3");

        // 生成一个JdbcTemplate实例
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

        String sql = " CREATE TABLE t_user2(user_id int primary key, user_name varchar(60)) ";
        jdbcTemplate.execute(sql);

    }

}
